package com.woniu.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniu.pojo.Heright;
import com.woniu.service.HerightService;
import com.woniu.service.HouseService;

@Controller
@RequestMapping("/heright")
public class HerightController {
	@Autowired
	private HerightService herightService;
	@Autowired
	private HouseService houseService;
	@RequestMapping("/addHeight")
	@ResponseBody
	public String addHeight(Heright heright,String house_id) {
		String heright_id="B"+house_id;
		heright.setHeright_id(heright_id);
		int rowCount = houseService.updateHouseJurisdictionType("他项权", heright_id, String.valueOf(heright.getH_id()));
		if(rowCount==0) {
			return "修改失败";
		}
		int height = herightService.addHeight(heright);
		if(height==0) {
			return "添加失败";
		}
		return "添加成功";
	}
	@RequestMapping("/skipHeright")
	public String skipHeright(String h_id,String house_id,HttpServletRequest request) {
		request.setAttribute("h_id", h_id);
		request.setAttribute("house_id", house_id);
		return "forward:/houseRegister/heright.jsp";
	}
}
